<?php
namespace app\modules\adminapi\controllers;

use fate\http\Request;
use app\models\UserRoles;
use app\libs\Util;

class AddroleController extends \app\modules\adminapi\ForceLoginPure {

    public function run() {
        $req = Request::getInstance();

        $roleName = Util::plainText($req->getParameter('role_name'));
        $roleDescribe = Util::plainText($req->getParameter('role_describe'));

        if(!$roleName || !$roleDescribe) {
            $this->ajaxReturn(null, 300002);
            exit;
        }

        $data = [
            'role_name' => $roleName,
            'role_describe' => $roleDescribe
        ];
        // var_dump($data);exit;

        $model = new UserRoles();
        $ret = $model->insert($data);

        $this->ajaxReturn(null);
    }

}
